$(function(){
	//查看最近登录系统的用户
	$('#findLatelyLoginUser').click(function() {
		findlatelyLoginUser(1);
	});
});
//获取信息列表
var latelyLoginUserPage = new Page('latelyLoginUserPage', findlatelyLoginUser, 'bodyInfo', 'bodyInfoPage');
latelyLoginUserPage.size = 5;
latelyLoginUserPage.pageSizeArr = [5, 10, 15];
//设置开始字符串
latelyLoginUserPage.beginString = '<table><thead><tr>'
							+'<th>编号</th>'
							+'<th>昵称</th>'
							+'<th>等级</th>'
							+'<th>粉丝数</th>'
							+'<th>关注数</th>'
							+'<th>新浪用户编号</th>'
							+'<th>登录时间</th>'
							+'<th>添加时间</th></tr></thead><tbody>';
//设置结束字符串
latelyLoginUserPage.endString = "</tbody></table>";
//处理Page标签的函数
function findlatelyLoginUser(_page) {
	if(_page != undefined) {
		latelyLoginUserPage.page = _page;
	}
	jQuery.ajax({
		url : webroot + '/statistics/json/findlatelyLoginUser.shtml',
		data : {
			'page' : latelyLoginUserPage.page,
			'size' : latelyLoginUserPage.size
		},
		type : 'POST',
		dataType : 'json',
		async : true,
		beforeSend: function(){
			//提交处理的函数
			latelyLoginUserPage.pageBeforeSend('<tr><td colspan="8">加载信息中...</td></tr>');
			loading('加载信息中...');
		},
		error : function(json){
			latelyLoginUserPage.pageError('<tr><td colspan="8">加载信息出错了~</td></tr>');
			unloading();
		},
		//返回的是一个对象
		success : function(json){
			if(json.result === 'success') {
				//处理数据列表的行信息
				function getResult(obj) {
					var result = '<tr><td>' + obj.id + '</td><td><a class="a_blue" href="http://weibo.com/u/' + obj.username + '" target="_banlk">' + obj.nickname + '</a></td><td>'
								+ obj.gradeid + '</td><td>'
								+ obj.fansnum + '</td><td>' + obj.attentionnum + '</td><td>' + obj.username + '</td><td>' + dateUtil.getFormatDate(new Date(obj.logintime)) + '</td><td>'
								+ dateUtil.getFormatDate(new Date(obj.createtime)) + '</td></tr>';
					return result;
				}
				latelyLoginUserPage.pageOperate(json.data, { resultFn : getResult, dataNull : '<tr><td colspan="8">没有查找到信息!</td></tr>', pageFootStyle : latelyLoginUserPage.pageStyle.defaultStyle });
			}
			else if(json.result === 'error_not_admin') {
				alert('您不是管理员!');
			}
			else if(json.result === 'error_weibo') {
				alert(json.weiboMsg);
			}
			else if(json.result === 'error') {
				alert('请求操作, 系统出现异常!');
			}
			unloading();
		}
	});
}